package com.dycloud.project.controller.user;

import com.dycloud.project.domain.MeetingReceipt;
import com.dycloud.project.request.MeetingReceiptRequest;
import com.dycloud.project.service.IMeetingReceiptService;
import com.dycloud.project.utils.SecurityUtils;
import com.dycloud.project.vo.MeetingReceiptListVO;
import com.dycloud.project.web.controller.BaseController;
import com.dycloud.project.web.domain.AjaxResult;
import com.dycloud.project.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author : renhang
 * @description MeetingReceiptController
 * @date : 2025-07-03 15:58
 **/
@RestController
@RequestMapping("/user/receipt")
public class UserMeetingReceiptController extends BaseController {
    @Autowired
    private IMeetingReceiptService meetingReceiptService;

    /**
     * 查询会议回执列表
     */
    @GetMapping("/list")
    public TableDataInfo list(MeetingReceipt meetingReceipt) {
        startPage();
        meetingReceipt.setUserId(SecurityUtils.getUserId());
        List<MeetingReceiptListVO> list = meetingReceiptService.selectUserMeetingReceiptList(meetingReceipt);
        return getDataTable(list);
    }

    /**
     * 用户填写回执单
     *
     * @param request request
     * @return: @return {@link AjaxResult }
     */

    @PostMapping("/write")
    public AjaxResult write(@RequestBody @Validated MeetingReceiptRequest request) {
        meetingReceiptService.write(request);
        return AjaxResult.success();
    }
}